package com.bang.study.producer;

import com.bang.study.constants.PublicConstants;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;

/**
 * @ClassName: OneWayProducer
 * @Desc: TODO
 * @Auther: <Bang>
 * @Date: 2020/05/06 18:10
 * @Version: 1.0
 * @Modified By:
 */
public class OneWayProducer {

    public static void main(String[] args) throws Exception{
        DefaultMQProducer producer = new DefaultMQProducer(PublicConstants.TEST_PRODUCER_GROUP);
        producer.setNamesrvAddr(PublicConstants.NAME_ADDR);
        producer.start();
        for (int i = 0; i < 3; i++) {
            String arg = "One WAY " + i;
            Message message = new Message(PublicConstants.TEST_TOPIC, "tag3", arg.getBytes());
            producer.sendOneway(message);
        }
        System.out.println("发送完成");
        Thread.sleep(5000);

        producer.shutdown();

    }
}
